package com.example.goods_admin;


import com.example.goods_admin.common.Result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class Person {

    protected static final String aa="aaaaQQQQ";









    private String id;





    private String name;

    private int age;

    private String address;

    protected static final String handle(){
        return "1";
    }

    @Override
    public String toString() {
        return "Person11111111111{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                '}';
    }

    public static void main(String[] args) {

        System.out.printf(Person.aa);



        Person person1 = new Person("1","tom",10,"111");
        Person person2 = new Person("2","tom",10,"111");
        Person person3 = new Person("3","tom",10,"111");

        String aa1 = person1.getId();
        Person.handle();

        Person person4 = new Person();
        person4.setId("4");
        person4.setName("cat");
        person4.setAge(100);
        person4.setAddress("111");

        System.out.println(person4.toString());
        System.out.println(person1.toString());

        //8种基本类型：int short long double,float,boolean,byte,char
        //
        /*

         */

        /**
         * Java 语言中有 8 种基本数据类型，它们分别是：
         *
         * byte：字节型，占用 1 个字节，取值范围为 -128 到 127。(一个字节位（2的7次方）-1)
         * short：短整型，占用 2 个字节，取值范围为 -32,768 到 32,767。
         * int：整型，占用 4 个字节，取值范围为 -2,147,483,648 到 2,147,483,647。
         * long：长整型，占用 8 个字节，取值范围为 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807。
         * float：单精度浮点型，占用 4 个字节，表示带小数的数值。
         * double：双精度浮点型，占用 8 个字节，表示带小数的数值。
         * char：字符型，占用 2 个字节，用来表示单个字符，如 'A'、'b' 等。
         * boolean：布尔型，占用 1 个字节，取值为 true 或 false。
         * 这些基本数据类型在 Java 中用于表示不同的数据种类，每种类型都有其特定的取值范围和存储大小。除了这些基本类型，Java 还提供了包装类（Wrapper Class）来处理基本类型的对象表示和操作。例如，Integer 是 int 的包装类，Double 是 double 的包装类，以此类推。这些包装类提供了更多的方法和功能，方便对基本类型进行操作和转换。
         */


        //引用类型
        String name="aaa";

        byte byte1=-128;
        Byte by=1;
        System.out.println(String.valueOf(Math.pow(2,15)-1));

        int age=10;
        Integer age1=100;

        //装箱、拆箱
        Integer integer = age;
        int i = age1;

        short age2=1;
        Short ah1=1;

        Boolean b=true;

        char sex1='汉';
        System.out.printf(String.valueOf(sex1));











        double v = age1.doubleValue();
        System.out.println(v);


        String [] array=new String[]{"1","2","3"};

        int [] array1=new int[]{1};
        System.out.printf(String.valueOf(array1));


        //数组
        Person [] personArray=new Person[]{person1};

        //集合
        List<Person> personist = new ArrayList<>();
        List<Result> people12 = new ArrayList<>();
        List<Person> people1 = new LinkedList<>();

        personist.add(person1);
        personist.add(person2);
        personist.add(person3);
        personist.add(person4);

        System.out.printf(String.valueOf(personist.isEmpty()));
        System.out.println(personist.size());
        personist.addAll(personist);

        for (int i1 = 0; i1 < personist.size(); i1++) {
            System.out.println(personist.get(i1).getId());
        }

        for (Person person5 : personist) {
            System.out.println(person5.getId());
        }

        for (int i1 = personist.size() - 1; i1 >= 0; i1--) {
            System.out.println(personist.get(i1).getId());
        }

        personist.forEach((item)->{
            System.out.println(item.getId());
        });

//        personist.remove(0);

        System.out.println("子集合");
        //子集合[1,3)
        List<Person> people = personist.subList(1, 3);
        for (Person person : people) {
            System.out.println(person.getId());
        }

        int i1 = personist.indexOf(person4);
        System.out.println(i1);


//        Person[] objects =(Person[]) personist.toArray();
//        List<Person> people2 = Arrays.asList(objects);

        Person person = personist.get(1);
        personist.set(2,person4);

        Set<String> strings1 = new HashSet<>();
        Set<String> strings2 = new TreeSet<>();

        strings1.add("1");
        strings1.add("2");

        System.out.println(strings1.size());

        Map<String, Integer> map = new HashMap<>();
        map.put("a", Integer.valueOf("10"));
        map.put("b",10);
        map.put("c",100);

        Integer c = map.get("c");

        map.put("b",11111);

        map.remove("a");

        LinkedHashMap<Object, Object> hashMap = new LinkedHashMap<>();

        TreeMap<String, Double> stringDoubleTreeMap = new TreeMap<>();

        //List:ArrayList,LinkedList
        //Set:HashSet,TreeSet
        //Map:HashMap,LinkedHashMap,TreeMap

        int aa=10;
        int bb=10;

        System.out.println(aa==bb);

        Person aaa = new Person("1", "a", 1, "1");
        Person bbb = new Person("1", "a", 1, "1");

        System.out.println(aaa==bbb);
        System.out.println(aaa.equals(bbb));


    }


}
